/*
 * @Author: Kevin Zhao
 * @Date: 2021-08-04 22:17:14
 * @LastEditTime: 2021-12-11 14:15:42
 * @LastEditors: Kevin Zhao
 * @Description: 地址管理页面接口
 * @FilePath: \uniapp-pro\src\api\address.ts
 */
import request from '../server/request'
import { DefaultAddress } from './config/enums'
import { sessionIdInterface, deleteInterface } from './config/interface'

interface AddAddressInterface extends sessionIdInterface {
    receiver: string, // 收货人
    mobile: number | string, // 手机号码
    province: number | string, // 省id
    city: number | string, // 市id
    district: number | string, // 区县id
    detail: string, // 详细地址
    is_default: DefaultAddress, // 是否默认地址
}

interface UpdateAddressInterface extends AddAddressInterface {
    id: number | string, // 地址id
}

/**
 * @description: 获取省市区
 * @param {*}
 * @return {*}
 */
export const getCityListAPI = (): any => {
    return request({
    }, 'getCityList')
}

/**
 * @description: 获取我的地址
 * @param {string} sessionId
 * @return {*}
 */
export const getAddressListAPI = (params: sessionIdInterface) => {
    return request(params, 'getUserAddRessList')
}

/**
 * @description: 新增我的地址
 * @param {AddAddressInterFace} params
 * @return {*}
 */
export const addAddressAPI = (
    params: AddAddressInterface,
) => {
    return request(params, 'addUserAddRess')
}

/**
 * @description: 修改我的地址
 * @param {UpdateAddressInterface} params
 * @return {*}
 */
export const updateAddressAPI = (params: UpdateAddressInterface): any => {
    return request(params, 'modifyUserAddRess')
}

/**
 * @description: 删除我的地址
 * @param {deleteInterface} params
 * @return {*}
 */
export const deleteAddressAPI = (params: deleteInterface): any => {
    return request(params, 'deleteUserAddRess')
}
